package com.corgi.multi.anno.service.impl;

import com.corgi.multi.anno.config.dynamic.TargetDataSource;
import com.corgi.multi.anno.dao.UserLoginRepository;
import com.corgi.multi.anno.domain.UserLogin;
import com.corgi.multi.anno.service.DataSourceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * DataSourceServiceImpl
 *
 * @title: DataSourceServiceImpl
 * @description:
 * @author: dengmiao
 * @create: 2020-05-21 19:45
 **/
@Service
public class DataSourceServiceImpl implements DataSourceService {

    @Autowired
    private UserLoginRepository dataSourceDao;

    @Override
    public List<UserLogin> selectById(Long id) {
        List<UserLogin> list = dataSourceDao.findAll();
        return list;
    }

    @Override
    @TargetDataSource(name = "ds1")
    public List<UserLogin> selectAllDs1() {
        List<UserLogin> list = dataSourceDao.findAll();
        return list;
    }

    @Override
    @TargetDataSource(name = "ds2")
    public List<UserLogin> selectAllDs2() {
        List<UserLogin> list = dataSourceDao.findAll();
        return list;
    }
}
